package com.wdl.sm.webui.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import com.wdl.sm.webui.yang.YangConfigCache;

@Component
public class WebuiApplicationContextListener implements ApplicationListener<ContextRefreshedEvent>{
    private static final Logger LOGGER = LoggerFactory.getLogger("WebuiApplicationContextListener");

    @Autowired
    YangConfigCache yangCache;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        LOGGER.info("Web application " + event.getApplicationContext().getApplicationName() + " was loaded, start cache initialization!");
        yangCache.init();
    }
}
